home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / iceweasel / modules / GcliCommands.jsm < prev    next >
Encoding:
Text File  |  2013-01-09  |  4.0 KB  |  142 lines

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3.  *
  4.  * The contents of this file are subject to the Mozilla Public License Version
  5.  * 1.1 (the "License"); you may not use this file except in compliance with
  6.  * the License. You may obtain a copy of the License at
  7.  * http://www.mozilla.org/MPL/
  8.  *
  9.  * Software distributed under the License is distributed on an "AS IS" basis,
  10.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11.  * for the specific language governing rights and limitations under the
  12.  * License.
  13.  *
  14.  * The Original Code is GCLI Commands.
  15.  *
  16.  * The Initial Developer of the Original Code is
  17.  * The Mozilla Foundation.
  18.  * Portions created by the Initial Developer are Copyright (C) 2011
  19.  * the Initial Developer. All Rights Reserved.
  20.  *
  21.  * Contributor(s):
  22.  *   Joe Walker <jwalker@mozilla.com> (original author)
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  26.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38.  
  39. let EXPORTED_SYMBOLS = [ "GcliCommands" ];
  40.  
  41. Components.utils.import("resource:///modules/gcli.jsm");
  42. Components.utils.import("resource:///modules/HUDService.jsm");
  43.  
  44.  
  45. /**
  46.  * 'echo' command
  47.  */
  48. gcli.addCommand({
  49.   name: "echo",
  50.   description: gcli.lookup("echoDesc"),
  51.   params: [
  52.     {
  53.       name: "message",
  54.       type: "string",
  55.       description: gcli.lookup("echoMessageDesc")
  56.     }
  57.   ],
  58.   returnType: "string",
  59.   exec: function Command_echo(args, context) {
  60.     return args.message;
  61.   }
  62. });
  63.  
  64.  
  65. let canon = gcli._internal.require("gcli/canon");
  66.  
  67. /**
  68.  * 'help' command
  69.  */
  70. gcli.addCommand({
  71.   name: "help",
  72.   returnType: "html",
  73.   description: gcli.lookup("helpDesc"),
  74.   exec: function Command_help(args, context) {
  75.     let output = [];
  76.  
  77.     output.push("<strong>" + gcli.lookup("helpAvailable") + ":</strong><br/>");
  78.  
  79.     let commandNames = canon.getCommandNames();
  80.     commandNames.sort();
  81.  
  82.     output.push("<table>");
  83.     for (let i = 0; i < commandNames.length; i++) {
  84.       let command = canon.getCommand(commandNames[i]);
  85.       if (!command.hidden && command.description) {
  86.         output.push("<tr>");
  87.         output.push('<th class="gcliCmdHelpRight">' + command.name + "</th>");
  88.         output.push("<td>→ " + command.description + "</td>");
  89.         output.push("</tr>");
  90.       }
  91.     }
  92.     output.push("</table>");
  93.  
  94.     return output.join("");
  95.   }
  96. });
  97.  
  98.  
  99. /**
  100.  * 'console' command
  101.  */
  102. gcli.addCommand({
  103.   name: "console",
  104.   description: gcli.lookup("consoleDesc"),
  105.   manual: gcli.lookup("consoleManual")
  106. });
  107.  
  108. /**
  109.  * 'console clear' command
  110.  */
  111. gcli.addCommand({
  112.   name: "console clear",
  113.   description: gcli.lookup("consoleclearDesc"),
  114.   exec: function(args, context) {
  115.     let hud = HUDService.getHudReferenceById(context.environment.hudId);
  116.     hud.gcliterm.clearOutput();
  117.   }
  118. });
  119.  
  120.  
  121. /**
  122.  * 'inspect' command
  123.  */
  124. gcli.addCommand({
  125.   name: "inspect",
  126.   description: gcli.lookup("inspectDesc"),
  127.   manual: gcli.lookup("inspectManual"),
  128.   params: [
  129.     {
  130.       name: "node",
  131.       type: "node",
  132.       description: gcli.lookup("inspectNodeDesc"),
  133.       manual: gcli.lookup("inspectNodeManual")
  134.     }
  135.   ],
  136.   exec: function Command_inspect(args, context) {
  137.     let hud = HUDService.getHudReferenceById(context.environment.hudId);
  138.     let InspectorUI = hud.gcliterm.document.defaultView.InspectorUI;
  139.     InspectorUI.openInspectorUI(args.node);
  140.   }
  141. });
  142.